﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Linn.Controls {
    public class ListEntry {
        internal ListEntry(int index, string text, string value) {
            this.Index = index;
            this.Text = text;
            this.Value = value;
        }

        public int Index { get; private set; }
        public string Text { get; private set; }
        public string Value { get; private set; }
    }

    public class ListEntries : IEnumerable<ListEntry> {
        private List<ListEntry> entries;

        public ListEntries() : this(6) { }

        public ListEntries(int capacity) {
            entries = new List<ListEntry>(capacity);
        }

        public ListEntry this[int index] { get { return entries[index]; } }

        public void Add(string text, string value) {
            ListEntry entry = new ListEntry(entries.Count + 1, text, value);
            entries.Add(entry);
        }

        public int Count { get { return entries.Count; } }

        public void Clear() { entries.Clear(); }

        public IEnumerator<ListEntry> GetEnumerator() {
            return entries.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator() {
            return GetEnumerator();
        }
    }
}
